/**  
 * All rights Reserved, Designed By www.flksh.com
 * @date:   2017-10-30 15:36:22   
 * @Copyright: 2013-2017 www.flksh.com Inc. All rights reserved. 
 * 注意：本内容仅限于上海福乐康社区养老服务有限公司内部传阅，禁止外泄以及用于其他的商业目
 */
package com.zx.cloud.service;

import java.time.OffsetDateTime;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zx.cloud.domain.OrderLog;
import com.zx.cloud.domain.User;
import com.zx.cloud.persistence.CrudMapper;
import com.zx.cloud.persistence.OrderLogMapper;
import com.zx.cloud.persistence.UserMapper;

/**
 * 订单日志表
 */
@Service
public class OrderLogService extends CrudServiceImpl<OrderLog>{
    
    private static final Logger LOGGER = LoggerFactory.getLogger(OrderLogService.class);
    @Autowired
	private UserMapper userMapper;
    @Autowired
	private OrderLogMapper orderLogMapper;
  	@Autowired
    public OrderLogService(CrudMapper<OrderLog> mapper) {
        super(mapper);
    }

  	public void  insertOrderLog(Long userId,Long orderId,int type,String opContent){
		/**订单操作日志*/
		OrderLog orderLog = new OrderLog();
		orderLog.setOrderType(type);// 1借款订单,2还款订单
		orderLog.setOrderId(orderId);
		User user = userMapper.get(userId);
		orderLog.setUpdateUserId(userId);
		orderLog.setUpdateUsername(user.getFullname());
		orderLog.setOpContent(opContent);
		orderLog.setCreateTime(OffsetDateTime.now());
		orderLogMapper.insert(orderLog);
	}
}
